#pragma once

#include <iostream>
#include <string>
#include <ctime>

#define NORMAL  1
#define WARNING 2
#define DEBUG   3
#define ERROR   4

#define LOG(LEVEL, MESSAGE) log(#LEVEL, MESSAGE, __FILE__, __LINE__)

void log(std::string level, std::string message, std::string file_name, int line)
{
    time_t timestamp;
    time(&timestamp); // 获取UTC 1970-01-01 00：00：00开始的unix时间戳
    tm* nowtime = localtime(&timestamp); // 将时间戳转化为本地时间
    /* 
        tm_mon ：从一月份开始的月份数 [0 - 11]
        tm_year：int 从1900年开始的年数 
    */
    printf("[%s] %4d-%02d-%02d %02d:%02d:%02d %s line：%d \"%s\"\n",level.c_str(),1900+nowtime->tm_year, \
        1 + nowtime->tm_mon,nowtime->tm_mday,nowtime->tm_hour,nowtime->tm_min,nowtime->tm_sec,file_name.c_str(),line,message.c_str());
}
